#ifndef _DISPATCH_STRUCT
#define _DISPATCH_STRUCT

#include <string>
#include <vector>



// separating data from structure allows more flexibility in relation to every modification in the form structure
class dispatch_struct_data
{
public:
	dispatch_struct_data(const char* _filename);

	enum
	{
		INPUT_ELEM_VALUE,
		DISPATCH_STRUCT_TOT_OP
	};

	static const char* DISPATCH_STRUCT_OP[DISPATCH_STRUCT_TOT_OP][2];
	std::vector< std::string > const& get_input_element_value();
	std::string const & get_input_data_filename();

	dispatch_struct_data& operator=(dispatch_struct_data const& t);
	dispatch_struct_data& operator=(std::string const& filename);

	friend std::ostream& operator << (std::ostream& ost, dispatch_struct_data const& c);

private:

	void init(void);
	std::string input_data_filename;
	std::vector< std::string > input_element_value;
};



// structure of HTML page and possible actions
class dispatch_struct
{
public:
	dispatch_struct(const char* _filename);
	dispatch_struct(std::string const _filename);

	enum input_type
	{
		TEXT,
		IMAGE,
		HIDDEN,
		PASSWORD,
		BUTTON,
		FORM_ACTION,
		JSCRIPT
	};
	
	enum encryption_task
	{
		DECRYPT,
		ENCRYPT
	};

	enum
	{
		URI,
		INPUT_ELEM_NAME,
		INPUT_ELEM_TYPE,
		INPUT_ELEM_VALUE,
		INPUT_ELEM_ENCRYPTION_CONFIG,
		ENCRYPTION_TASK,
		NEXT_DISPATCH_FILE,
		POSTING_URL_ENCODED,
		INPUT_ELEMENT_NAME_REGEX,
		INPUT_DATA_FILENAME,
		DISPATCH_STRUCT_TOT_OP
	};

	static const char* DISPATCH_STRUCT_OP[DISPATCH_STRUCT_TOT_OP][2];

	std::string const& get_URI();
	std::vector< std::string > const& get_input_element_name();
	std::vector< input_type > const& get_input_element_type();
	std::vector< std::string > const& get_input_element_value();
	std::vector< std::string > const& get_input_element_encryption();
	std::vector< encryption_task > const& get_input_encryption_task_type();

	std::string const& get_dispatch_struct_filename();
	std::string const& get_next_dispatch_filename();
	std::string const& get_input_data_filename();

	dispatch_struct& operator=(dispatch_struct const& t);
	friend std::ostream& operator << (std::ostream& ost, dispatch_struct const& c);

	dispatch_struct_data const& get_dispatch_struct_input_data();

	bool post_url_encoded_data();	

private:
	std::string _URI;

	std::vector< std::string > input_element_name;
	std::vector< input_type > input_element_type;
	std::vector< encryption_task > encryption_task_type;
	std::vector< std::string > input_element_encryption;
	std::vector< std::string > input_element_value;

	std::string dispatch_struct_filename;
	std::string next_dispatch_struct_filename;
	std::string input_data_filename;

	bool posting_url_encoded;
	
	std::string input_element_name_regex;

	void init(void);
};


#endif

